library(readr)
setwd("${path}")
demo <- read_csv("logistic.csv")
a = strsplit(demo$`95% CI`, "-", fixed= T)
a <- t(as.data.frame(a))
colnames(a) <- c("CI_low","CI_up")
rownames(a) <- c(demo$Variable)
demo <- cbind(demo,a)
library(ggplot2)
demo$CI_low <-  as.numeric(demo$CI_low)
demo$CI_up <-  as.numeric(demo$CI_up)
Cairo::CairoTIFF(file="forestMap.tiff", width=${imgW}, height=${imgH},units="in",dpi=150)
p <- ggplot(demo, aes(x = Variable,y = OR, ymin = CI_low, ymax = CI_up)) +
  geom_point(colour = "red") +
  geom_errorbar(aes(ymin=CI_low, ymax=CI_up),width=0.2)+ theme_bw()+
  theme(plot.title=element_text(size=16,face="bold"),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank(),
        axis.text.x=element_text(face="bold"),
        axis.title=element_text(size=12,face="bold"),
        strip.text.y = element_text(hjust=0,vjust = 1,angle=180,face="bold"),
        panel.grid.major = element_blank(),panel.grid.minor = element_blank())+
  coord_flip()+
  xlab("Adjusted association(odds ratio of death)for individual patient factors retained the\n  multivariate mortality prediction model")+
  ylab("Odds ratio of death")
#+geom_text(aes(label=Disease))
p <- p + theme(axis.title.x =element_text(size=10), axis.title.y=element_text(size=10))
p <- p+ylim(0, 5)
library(dplyr)

p2 <- demo |>  
  dplyr::mutate(x = "col2") |> 
  ggplot(aes(x=x,y=Variable))+
  geom_text(aes(label=Variable))+
  theme_minimal()+
  theme(axis.text = element_blank(),
        axis.ticks = element_blank(),
        axis.title.y = element_blank(),
        panel.grid.major = element_blank(),panel.grid.minor = element_blank()
  )+
  labs(x="Disease")+
  scale_x_discrete(position = "top")
#因为分数为论文自己计算,无法通过程序获取
#p3 <- demo |>  
#  mutate(x = "col3") |> 
#  ggplot(aes(x=x,y=Variable))+
#  geom_text(aes(label=Points))+
#  theme_minimal()+
#  theme(axis.text = element_blank(),
#        axis.ticks = element_blank(),
#        axis.title.y = element_blank(),
#        panel.grid.major = element_blank(),panel.grid.minor = element_blank()
#  )+
#  labs(x="Points")+
#  scale_x_discrete(position = "top")
#ggpubr::ggarrange(p, p2)
library(patchwork)
p+p2
